{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Naive Bayes Classification"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>pregnant</th>\n",
       "      <th>glucose</th>\n",
       "      <th>bp</th>\n",
       "      <th>skin</th>\n",
       "      <th>insulin</th>\n",
       "      <th>bmi</th>\n",
       "      <th>pedigree</th>\n",
       "      <th>age</th>\n",
       "      <th>label</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>6</td>\n",
       "      <td>148</td>\n",
       "      <td>72</td>\n",
       "      <td>35</td>\n",
       "      <td>0</td>\n",
       "      <td>33.6</td>\n",
       "      <td>0.627</td>\n",
       "      <td>50</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>85</td>\n",
       "      <td>66</td>\n",
       "      <td>29</td>\n",
       "      <td>0</td>\n",
       "      <td>26.6</td>\n",
       "      <td>0.351</td>\n",
       "      <td>31</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>8</td>\n",
       "      <td>183</td>\n",
       "      <td>64</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>23.3</td>\n",
       "      <td>0.672</td>\n",
       "      <td>32</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>89</td>\n",
       "      <td>66</td>\n",
       "      <td>23</td>\n",
       "      <td>94</td>\n",
       "      <td>28.1</td>\n",
       "      <td>0.167</td>\n",
       "      <td>21</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>137</td>\n",
       "      <td>40</td>\n",
       "      <td>35</td>\n",
       "      <td>168</td>\n",
       "      <td>43.1</td>\n",
       "      <td>2.288</td>\n",
       "      <td>33</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   pregnant  glucose  bp  skin  insulin   bmi  pedigree  age  label\n",
       "0         6      148  72    35        0  33.6     0.627   50      1\n",
       "1         1       85  66    29        0  26.6     0.351   31      0\n",
       "2         8      183  64     0        0  23.3     0.672   32      1\n",
       "3         1       89  66    23       94  28.1     0.167   21      0\n",
       "4         0      137  40    35      168  43.1     2.288   33      1"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Import libraries\n",
    "import pandas as pd\n",
    " \n",
    "# read the dataset\n",
    "diabetes = pd.read_csv(\"diabetes.csv\")\n",
    " \n",
    "    \n",
    "# Show top 5-records\n",
    "diabetes.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# split dataset in two parts: feature set and target label \n",
    "feature_set = ['pregnant', 'insulin', 'bmi', 'age','glucose','bp','pedigree']\n",
    "features = diabetes[feature_set] \n",
    "target = diabetes.label\n",
    " \n",
    "# partition data into training and testing set \n",
    "from sklearn.model_selection import train_test_split\n",
    "feature_train, feature_test, target_train, target_test = train_test_split(features, target, test_size=0.3, random_state=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Import Gaussian Naive Bayes model\n",
    "from sklearn.naive_bayes import GaussianNB\n",
    "\n",
    "# Create a Gaussian Classifier\n",
    "model = GaussianNB()\n",
    " \n",
    "# Train the model using the training sets\n",
    "model.fit(feature_train,target_train)\n",
    " \n",
    "# Forecast the target variable for given test dataset\n",
    "predictions = model.predict(feature_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy: 0.7748917748917749\n",
      "Precision: 0.7391304347826086\n",
      "Recall: 0.6\n",
      "F1-Score: 0.6623376623376623\n"
     ]
    }
   ],
   "source": [
    "# Import metrics module for performance evaluation\n",
    "from sklearn.metrics import accuracy_score\n",
    "from sklearn.metrics import precision_score\n",
    "from sklearn.metrics import recall_score\n",
    "from sklearn.metrics import f1_score\n",
    " \n",
    "# Calculate model accuracy\n",
    "print(\"Accuracy:\",accuracy_score(target_test, predictions))\n",
    "# Calculate model precision\n",
    "print(\"Precision:\",precision_score(target_test, predictions))\n",
    "# Calculate model recall\n",
    "print(\"Recall:\",recall_score(target_test, predictions))\n",
    "# Calculate model f1 score\n",
    "print(\"F1-Score:\",f1_score(target_test, predictions))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Decision Tree Classification"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy: 0.7056277056277056\n",
      "Precision: 0.6133333333333333\n",
      "Recall: 0.5411764705882353\n",
      "F1-Score: 0.575\n"
     ]
    }
   ],
   "source": [
    "# Import Decision Tree model \n",
    "from sklearn.tree import DecisionTreeClassifier\n",
    "\n",
    "# Import metrics module for performance evaluation\n",
    "from sklearn.metrics import accuracy_score\n",
    "from sklearn.metrics import precision_score\n",
    "from sklearn.metrics import recall_score\n",
    "from sklearn.metrics import f1_score\n",
    " \n",
    "# Create a Decision Tree classifier object\n",
    "clf = DecisionTreeClassifier()\n",
    " \n",
    "# Train the model using training dataset\n",
    "clf = clf.fit(feature_train,target_train)\n",
    " \n",
    "# Predict the response for test dataset\n",
    "predictions = clf.predict(feature_test)\n",
    " \n",
    "# Calculate model accuracy\n",
    "print(\"Accuracy:\",accuracy_score(target_test, predictions))\n",
    "# Calculate model precision\n",
    "print(\"Precision:\",precision_score(target_test, predictions))\n",
    "# Calculate model recall\n",
    "print(\"Recall:\",recall_score(target_test, predictions))\n",
    "# Calculate model f1 score\n",
    "print(\"F1-Score:\",f1_score(target_test, predictions))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## K-Nearest Neighbors Classification"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy: 0.7532467532467533\n",
      "Precision: 0.7058823529411765\n",
      "Recall: 0.5647058823529412\n",
      "F1-Score: 0.6274509803921569\n"
     ]
    }
   ],
   "source": [
    "# Import KNN model\n",
    "from sklearn.neighbors import KNeighborsClassifier\n",
    " \n",
    "# Create a KNN classifier object\n",
    "model = KNeighborsClassifier(n_neighbors=3)\n",
    " \n",
    "# Train the model using the training dataset\n",
    "model.fit(feature_train,target_train)\n",
    " \n",
    "# Predict the target variable for test dataset\n",
    "predictions = model.predict(feature_test)\n",
    " \n",
    "# Import metrics module for performance evaluation\n",
    "from sklearn.metrics import accuracy_score\n",
    "from sklearn.metrics import precision_score\n",
    "from sklearn.metrics import recall_score\n",
    "from sklearn.metrics import f1_score\n",
    " \n",
    "# Calculate model accuracy\n",
    "print(\"Accuracy:\",accuracy_score(target_test, predictions))\n",
    "# Calculate model precision\n",
    "print(\"Precision:\",precision_score(target_test, predictions))\n",
    "# Calculate model recall\n",
    "print(\"Recall:\",recall_score(target_test, predictions))\n",
    "# Calculate model f1 score\n",
    "print(\"F1-Score:\",f1_score(target_test, predictions))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## SVM Classification"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy: 0.7532467532467533\n",
      "Precision: 0.7058823529411765\n",
      "Recall: 0.5647058823529412\n",
      "F1-Score: 0.6274509803921569\n"
     ]
    }
   ],
   "source": [
    "# Import SVM model\n",
    "from sklearn import svm\n",
    " \n",
    "# Create a SVM classifier object\n",
    "clf = svm.SVC(kernel='linear') \n",
    " \n",
    "# Train the model using the training sets\n",
    "clf.fit(feature_train,target_train)\n",
    " \n",
    "# Predict the target variable for test dataset\n",
    "y_pred = clf.predict(feature_test)\n",
    " \n",
    "# Import metrics module for performance evaluation\n",
    "from sklearn.metrics import accuracy_score\n",
    "from sklearn.metrics import precision_score\n",
    "from sklearn.metrics import recall_score\n",
    "from sklearn.metrics import f1_score\n",
    " \n",
    "# Calculate model accuracy\n",
    "print(\"Accuracy:\",accuracy_score(target_test, predictions))\n",
    "# Calculate model precision\n",
    "print(\"Precision:\",precision_score(target_test, predictions))\n",
    "# Calculate model recall\n",
    "print(\"Recall:\",recall_score(target_test, predictions))\n",
    "# Calculate model f1 score\n",
    "print(\"F1-Score:\",f1_score(target_test, predictions))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Confusion Matrix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<sklearn.metrics._plot.confusion_matrix.ConfusionMatrixDisplay at 0x7f53cd9d9f98>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAATgAAAEKCAYAAACGzUnMAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYi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OzArLAWdmheWAM7PCcsCZWWE54MyssBxwZlZY/wv08mEZ+rdYRwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Import libraries\n",
    "import pandas as pd\n",
    " \n",
    "# read the dataset\n",
    "diabetes = pd.read_csv(\"diabetes.csv\")\n",
    "\n",
    "# split dataset in two parts: feature set and target label \n",
    "feature_set = ['pregnant', 'insulin', 'bmi', 'age','glucose','bp','pedigree']\n",
    "features = diabetes[feature_set] \n",
    "target = diabetes.label\n",
    " \n",
    "# partition data into training and testing set \n",
    "from sklearn.model_selection import train_test_split\n",
    "feature_train, feature_test, target_train, target_test = train_test_split(features, target, test_size=0.3, random_state=1)\n",
    "\n",
    "# import logistic regression scikit-learn model\n",
    "from sklearn.linear_model import LogisticRegression\n",
    "from sklearn.metrics import accuracy_score # for performance evaluation\n",
    " \n",
    "# instantiate the model\n",
    "logreg = LogisticRegression(solver='lbfgs')\n",
    " \n",
    "# fit the model with data\n",
    "logreg.fit(feature_train,target_train)\n",
    " \n",
    "# Forecast the target variable for given test dataset\n",
    "predictions = logreg.predict(feature_test)\n",
    "\n",
    "# Get prediction probability \n",
    "predictions_prob = logreg.predict_proba(feature_test)[::,1]\n",
    "\n",
    "\n",
    "# Import the confusion matrix\n",
    "from sklearn.metrics import plot_confusion_matrix\n",
    "\n",
    "# Plot Confusion matrix\n",
    "plot_confusion_matrix(logreg , feature_test, target_test, values_format='d')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Confusion Report"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "      Yes(1)       0.79      0.90      0.84       146\n",
      "       No(0)       0.78      0.58      0.66        85\n",
      "\n",
      "    accuracy                           0.78       231\n",
      "   macro avg       0.78      0.74      0.75       231\n",
      "weighted avg       0.78      0.78      0.78       231\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# import classification report\n",
    "from sklearn.metrics import classification_report\n",
    "\n",
    "# Create classification report\n",
    "print(classification_report(target_test, predictions, target_names=['Yes(1)','No(0)']))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## ROC Curve and AUC"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<sklearn.metrics._plot.roc_curve.RocCurveDisplay at 0x7f53cda55eb8>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3XmcFNW5//HPI6iggvcn20WRAAphHUYYEAJG+KGCRsEYUBEFrhqUBCGLeMnPXOWqScAYEjdENCz6YjOu3MgVl6gYFGVk3wRE0EF+iizKlbA/94/qqfT0bD3D1PRM9/f9es2LrqrTVU/1MP3UOafqHHN3REREAE5IdQAiIlJ1KCmIiEhISUFEREJKCiIiElJSEBGRkJKCiIiElBRERCSkpCAiIiElBRERCdVMdQBlVb9+fW/WrFmqwxARqVY+/PDDr9y9QWnlql1SaNasGbm5uakOQ0SkWjGzbcmUU/ORiIiElBRERCSkpCAiIiElBRERCSkpiIhIKLKkYGbTzOxLM1tTzHYzs4fMbLOZrTKzTlHFIiIiyYmypjAD6FfC9kuBlrGfEcBjEcYiIiJJiOw5BXdfZGbNSigyAHjKg/lAl5jZv5hZY3ffEVVMIiLVwez3P+WlFdsLrW97Zl3uvqJdpMdOZ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Vu35rnnngPgkUceYfr06ccVW1GUFESqgDPPPLPQl1W8xKRQWvl8s2bNYuXKlfzkJz9h7NixFRLrkSNHKmQ/99xzDxdddFGF7Ou3v/0tt912W7i8d+9eli1bxt69e/nkk0+S2seBAwf4wQ9+wMiRI9m8eTPr169n5MiR7Ny587himzBhAn369GHTpk306dOHCRMmFCrz7rvvsnjxYlatWsWaNWtYunQpb7/9NgC/+c1vaNiwIRs3bmTdunVceOGFANx444089NBDxxVbUZQURCKwbds2+vTpQ1ZWFn369OHTTz8F4OOPP6Zbt2506dKFu+66K7xK3bp1K+3btwdg7dq1dO3alezsbLKysti0aRPjxo3j448/Jjs7m7FjxxYof/ToUW6//XY6dOhAVlYWDz/8cKF4unfvzvbt28PlV199le7du9OpUycGDRrE//zP/wCwYMECWrduTc+ePRk9ejSXX345AOPHj2fEiBFccsklDB06lKNHjzJ27Fi6dOlCVlYWjz/+OAA7duzg+9//PtnZ2bRv35533nmHo0ePMnz4cNq3b0+HDh344x//CBS8an/jjTc477zz6NChAzfeeCMHDx4EoFmzZtx999106tSJDh06sGHDhkLntm/fPlatWkXHjh3Ddc899xxXXHEF1157LXPnzk3qdzZ79my6d+/OFVdcEa7r3bt3+DmX10svvcSwYcMAGDZsGC+++GKhMmbGgQMHOHToEAcPHuTw4cM0atQIgGnTpvGrX/0KgBNOOIH69esDcMopp9CsWTM++OCD44ovke4+krTxn/+1lnWff1Oh+2x7Zl3uvqJdmd83atQohg4dyrBhw5g2bRqjR4/mxRdfZMyYMYwZM4bBgwczZcqUIt87ZcoUxowZw5AhQzh06BBHjx5lwoQJrFmzJmwC2rp1a1h+6tSpfPLJJyxfvpyaNWuye/fuQvt85ZVXuPLKKwH46quvuO+++3j99dc59dRTmThxIpMmTeKOO+7glltuYdGiRTRv3pzBgwcX2MeHH37I3//+d2rXrs3UqVM5/fTTWbp0KQcPHqRHjx5ccsklPP/88/Tt25c777yTo0ePsn//flasWMH27dtZs2YNEFzFxztw4ADDhw/njTfeoFWrVgw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rfsSuNjdOwHXAA8V8b5bgQfdPZvgSzkvNuzBNUCP2PqjwJBSjn8FsNrMagEzgGvcvQPBCAAjzewM4IdAO3fPAu6Lf7O7PwvkElzRZ7v7P+I2PwtcFbd8DTCvnHH2IxjWIt+d7p4DZAEXmlmWuz9EMC5Ob3fvHRv64tfARbHPMhf4RSnHkQySdsNcSFr4R+yLMd6JwCOxNvSjBGP6JHoPuNPMmgDPu/smM+sDdAaWxob3qE2QYIoyy8z+AWwlGH75u8An7r4xtn0m8FPgEYL5GZ40s5eBpIfmdvedZrYlNmbNptgxFsf2W5Y4TyUY9iF+1q2rzWwEwd91Y4IJZ1YlvLdbbP3i2HFOIvjcRAAlBak+fg58AXQkqOEWmjTH3Web2fvAD4CFZnYzwTDDM939V0kcY0j8gHlmVuQcG7HxeLoSDMJ2LTAK+L9lOJd5wNXABuAFd3cLvqGTjpNgBrIJwKPAVWbWHLgd6OLue8xsBsHAcIkMeM3dB5chXskgaj6S6uJ0YEdsjPwbCK6SCzCzFsCWWJPJfIJmlDeAgWbWMFbmDEt+fuoNQDMzOze2fAPwdqwN/nR3X0DQiVvUHUD7CIbvLsrzwJUE8wDMi60rU5zufpigGahbrOmpLvAt8LWZNQIuLSaWJUCP/HMys1PMrKhal2QoJQWpLiYDw8xsCUHT0bdFlLkGWGNmK4DWBFMWriP48nzVzFYBrxE0rZTK3Q8QjED5FzNbDRwDphB8wf41tr+3CWoxiWYAU/I7mhP2uwdYB3zH3T+IrStznLG+ij8At7v7SoK5mdcC0wiapPJNBf7bzN50950Ed0bNiR1nCcFnJQJolFQREYmjmoKIiISUFEREJKSkICIiISUFEREJKSmIiEhISUFEREJKCiIiElJSEBGR0P8CjZNMptc7QGgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# import plot_roc_curve\n",
    "from sklearn.metrics import plot_roc_curve\n",
    "\n",
    "plot_roc_curve(logreg, feature_test, target_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Area Under Curve: 0.8628525382755843\n"
     ]
    }
   ],
   "source": [
    "# import roc auc score\n",
    "from sklearn.metrics import roc_auc_score\n",
    "\n",
    "# Compute the area under ROC curve\n",
    "auc = roc_auc_score(target_test, predictions_prob)\n",
    "\n",
    "# Print auc value\n",
    "print(\"Area Under Curve:\",auc)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
